package cn.doitedu.demo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.io.FileUtils;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieSession;
import org.kie.internal.utils.KieHelper;

import java.io.File;
import java.io.IOException;

public class DroolsDemo {

    public static void main(String[] args) throws IOException {
        KieHelper kieHelper = new KieHelper();
        String code = FileUtils.readFileToString(new File("realtime_rule/rules/rule_demo.drl"), "utf-8");
        kieHelper.addContent(code, ResourceType.DRL);
        KieSession kieSession = kieHelper.build().newKieSession();

        Ep ep = new Ep(2,false);
        Event e = new Event("bbb", ep);

        kieSession.insert(e);
        kieSession.fireAllRules();
        System.out.println(e.getEp().isHit());
    }
}